package org.example.cet.demos.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.example.cet.demos.converter.converter;
import org.example.cet.demos.domain.PageBean;
import org.example.cet.demos.domain.po.HwManage;
import org.example.cet.demos.domain.query.HwManageQuery;
import org.example.cet.demos.mapper.HwManageMapper;
import org.example.cet.demos.service.IHwManageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hq
 * @since 2024-12-18
 */
@Service
@RequiredArgsConstructor
public class HwManageServiceImpl extends ServiceImpl<HwManageMapper, HwManage> implements IHwManageService {
    private final converter converter;

    public PageBean getPage(HwManageQuery hwManageQuery){
        Page<HwManage> page=new Page<>(hwManageQuery.getCurrentPage(), hwManageQuery.getPageSize());
        lambdaQuery()
                .eq(!StrUtil.isBlankIfStr(hwManageQuery.getTitle()),HwManage::getTitle,hwManageQuery.getTitle())
                .eq(!StrUtil.isBlankIfStr(hwManageQuery.getDueTime()),HwManage::getDueTime,hwManageQuery.getDueTime())
                .page(page);
        PageBean pageBean=new PageBean();
        pageBean.setTotal(page.getTotal());
        pageBean.setRows(page.getRecords());
        return pageBean;
    }
}
